<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="renderer" content="webkit">
		<link href="../../css/bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" href="../../js/jquery-easyui-1.4.4/themes/bootstrap/easyui.css">
		<link rel="stylesheet" href="../../js/jquery-easyui-1.4.4/themes/icon.css">
		<link rel="stylesheet" href="../../css/ext_icon.css">
		<script src="../../js/jquery-easyui-1.4.4/jquery.min.js"></script>
		<script src="../../js/bootstrap.min.js"></script>
		<script src="../../js/jquery-easyui-1.4.4/jquery.easyui.min.js"></script>
		<script src="../../js/jquery-easyui-1.4.4/locale/easyui-lang-zh_CN.js"></script>
		<script src="../../js/ext_jquery.js"></script>
		<script src="../../js/ext_easyui.js"></script>
		<script src="../../js/jquery.form.js"></script>
		<script src="../../js/My97DatePicker/WdatePicker.js"></script>
		<script src="../../js/Chart.min.js"></script>
		<script src="../../js/util.js"></script>
		<script src="../../js/ckeditor/ckeditor.js"></script>
		<link rel="stylesheet" href="../../css/style.css">
		<script src="../../js/main.js"></script>
		<title></title>
		<script>
			var dataGrid;
			$(function() {
				dataGrid = $('#datetable')
					.datagrid({
						url: '6-3.json', //请求地址
						fit: true, //自动补全
						fitColumns: false, //列是否自适应宽度
						striped: false, //隔行颜色
						collapsible: false, //是否可改变列宽
						singleSelect: true, //单一选中行
						border: true,
						pagination: true, //是否分页
						rownumbers: true, //是否显示行号列
						idField: 'id',
						pageSize: 20,
						pageList: [10, 20, 30, 40, 50],
						remoteSort: false, //是否通过远程排序
						nowrap: false, //是否强制不换行显示内容
						checkOnSelect: false,
						frozenColumns: [
							[{
								field: 'id',
								title: '列1',
								width: 150,
								align: 'center',
								sortable: false
							}]
						],
						columns: [
							[{
								field: 'low1',
								title: '列2',
								width: 270,
								align: 'center',
								sortable: false
							}, {
								field: 'low2',
								title: '列3',
								width: 300,
								align: 'center',
								sortable: false
							}, {
								field: 'action',
								title: '操作',
								width: 100,
								align: 'center',
								sortable: false,
								formatter: function(value, row) {
									var str = '';
									str += $
										.formatString(
											'<img onclick="edit(\'{0}\');" src="{1}" title="修改"/>&nbsp;',
											row.id,
											'../../images/ext_icons/pencil.png');
									str += $
										.formatString(
											'<img onclick="del(\'{0}\');" src="{1}" title="删除"/>&nbsp;',
											row.id,
											'../../images/ext_icons/delete.png');
									str += $
										.formatString(
											'<img onclick="once(\'{0}\');" src="{1}" title="明细"/>&nbsp;',
											row.id,
											'../../images/ext_icons/shield.png');
									return str;
								}
							}]
						],
						toolbar: [{
							text: '增加',
							iconCls: 'icon-add',
							handler: function() {
								add();
							}
						}]
					});
			});

			function add() {
				var dialog = parent.$.modalDialog({
					title: '添加',
					width: 500,
					height: 300,
					href: 'html/menu/add.html',
					buttons: [{
						text: '提交',
						handler: function() {
							// parent.$.modalDialog.openner_dataGrid = dataGrid;
							// var f = parent.$.modalDialog.handler.find('.form-table');
							// f.submit();
							parent.$.messager.progress({
								title: '提示',
								text: '数据保存中，请稍后....'
							});
							setTimeout(function() {
								parent.$.messager.progress('close');
								parent.$.messager.show({
									title: '提示',
									msg: '新增成功!',
									timeout: 3000
								});
								parent.$.modalDialog.handler.dialog('close');
							}, 1200);
						}
					}, {
						text: '关闭',
						handler: function() {
							parent.$.modalDialog.handler.dialog('close');
						}
					}]
				});
			}

			function edit(id) {
				var dialog = parent.$
					.modalDialog({
						title: '编辑：' + id,
						width: 500,
						height: 300,
						href: 'html/menu/edit.html',
						buttons: [{
							text: '提交',
							handler: function() {
								//parent.$.modalDialog.openner_dataGrid = dataGrid;
								//var f = parent.$.modalDialog.handler.find('.form-table');
								//f.submit();
								parent.$.messager.progress({
									title: '提示',
									text: '数据保存中，请稍后....'
								});
								setTimeout(function() {
									parent.$.messager.progress('close');
									parent.$.messager.show({
										title: '提示',
										msg: '修改成功!',
										timeout: 3000
									});
									parent.$.modalDialog.handler.dialog('close');
								}, 1200);
							}
						}, {
							text: '关闭',
							handler: function() {
								parent.$.modalDialog.handler
									.dialog('close');
							}
						}]
					});
			}

			function once(id) {
				var url = "html/menu/once.html";
				openTabs(url, '明细：' + id, 1);
			}

			function del(id) {
				parent.$.messager
					.confirm(
						'确认',
						'您是否要删除？',
						function(r) {
							if (r) {
								$.messager.show({
									title: '提示',
									msg: '删除成功!',
									timeout: 3000
								});
								dataGrid.datagrid('load');
								dataGrid
									.datagrid(
										'uncheckAll')
									.datagrid(
										'unselectAll')
									.datagrid(
										'clearSelections');
							}
						});
			}
		</script>
	</head>

	<body>
		<table id="datetable"></table>
	</body>

</html>